package com.galengao.rabbitmq.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * properties加载
 */
public class PropertiesLoader {

    private PropertiesLoader() {}

    /**
     * 读取Properties属性
     * @see java.util.Properties
     * @param prop 配置文件名称
     * @return 读取的Properties对象
     */
    public static Properties getProps(String prop){
        Properties properties = new Properties();
        try {
            InputStream resource = PropertiesLoader.class.getClassLoader().getResourceAsStream(prop);
            properties.load(resource);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return properties;
    }

    public static void main(String[] args) {
        Properties properties = getProps("rabbitmq.properties");
        System.out.println(properties);
    }
}
